package org.oschina.api.user.active.dao;

import java.util.List;
import org.oschina.api.BaseDAO;
import org.oschina.api.user.active.model.UserActiveType;
import org.oschina.api.user.active.vo.UserActiveTypeVo;
import org.springframework.stereotype.Repository;

@Repository
public class UserActiveTypeDAO extends BaseDAO {

	private final String findVo[]={"id","name","message","url"};
	
	/**
	 * 返回
	 * @return
	 */
	public List<UserActiveTypeVo> findVo()
	{
		return getQueryHelper().query_cache(findVo,null,null,null,UserActiveTypeVo.class,-1,-1);
	}
	
	/**
	 * 根据ID返回
	 * @param id
	 * @return
	 */
	public UserActiveTypeVo findVoById(int id)
	{
		return (UserActiveTypeVo) getQueryHelper().queryForObject_cache(findVo, new String[]{"id=?"}, new Object[]{id}, UserActiveTypeVo.class);
	}
	
	/**
	 * 更新
	 * @param userActiveType
	 * @return
	 */
	public int update(UserActiveType userActiveType)
	{
		return (int) getQueryHelper().update_cache(new String[]{"name=?","message=?","url=?"},
				new String[]{"id=?"},
				new Object[]{userActiveType.getName(),userActiveType.getMessage(),userActiveType.getUrl(),userActiveType.getId()},UserActiveTypeVo.class);
	}
}